﻿using Orleans;
using Pay.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Pay.Model.Model;
using Pay.Container;
using Pay.Dal;
using Pay.Model.Interfaces;
using Pay.Model.Dto;

namespace Pay.ServiceImplement
{
    public class OrderServiceImplement : Grain, IOrderService
    {
        /// <summary>
        /// 统计
        /// </summary>
        /// <param name="searchWord"></param>
        /// <param name="merchantId"></param>
        /// <param name="timeBegin"></param>
        /// <param name="timeEnd"></param>
        /// <param name="offset"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        public async Task<IPagedOutput<StatisticModel>> GetPageStatistic(string searchWord, long? merchantId, DateTime? timeBegin = null, DateTime? timeEnd = null, int offset = 10, int rows = 1)
        {
            var instance = LocManager.Resolve<IOrderDal>();
            return await instance.GetPageStatistic(searchWord, merchantId, timeBegin, timeEnd, offset, rows);
        }

        public async Task<OrderInfo> GetById(long orderId)
        {
            var instance = LocManager.Resolve<IOrderDal>();
            return await instance.GetById(orderId);
        }
        public async Task<long> Add(OrderInfo model)
        {
            var instance = LocManager.Resolve<IOrderDal>();
            return await instance.Add(model);
        }

        public async Task<bool> Update(OrderInfo model)
        {
            var instance = LocManager.Resolve<IOrderDal>();
            return await instance.Update(model);
        }
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="searchWord"></param>
        /// <param name="merchantId"></param>
        /// <param name="timeBegin"></param>
        /// <param name="timeEnd"></param>
        /// <param name="offset"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        public async Task<IPagedOutput<OrderInfo>> GetPage(string searchWord, long? merchantId, DateTime? timeBegin = null, DateTime? timeEnd = null, int offset = 10, int rows = 1)
        {
            var instance = LocManager.Resolve<IOrderDal>();
            return await instance.GetPage(searchWord, merchantId, timeBegin, timeEnd, offset, rows);
        }
    }
}
